import logging

from selenium.webdriver.chrome import webdriver
from selenium.webdriver.support.wait import WebDriverWait

from common.doLog import DoLog
# from pages.shoppingCar import logger

logger=DoLog().set_get_logger(logging.INFO)
class BasePage():
    def __init__(self,d=None):
        if d is None:
            self.login = webdriver.WebDriver()
        else:
            self.login:webdriver=d
    def getElment(self,locater):
        try:
            e=WebDriverWait(self.login,10,1).until(lambda x:x.find_element(*locater))
        except Exception as e1:
            logger.error(f"发生了异常，查找元素失败{locater}，错误元素{e1}")
        else:
            logger.info(f"查找元索{locater}成功")
            return e
        finally:
            logger.info("查找元素结束!")
